define('payinfo/query',function(){
	var ViewModel = function(){
		toastr.options = {
				  "closeButton": true,
				  "debug": false,
				  "progressBar": true,
				  "positionClass": "toast-top-full-width",
				  "onclick": null,
				  "showDuration": "300",
				  "hideDuration": "1000",
				  "timeOut": "3000",
				  "extendedTimeOut": "1000",
				  "showEasing": "swing",
				  "hideEasing": "linear",
				  "showMethod": "fadeIn",
				  "hideMethod": "fadeOut"
				}
		var self = this;
		var url ="/payinfo/doFindObject";
		var params = {
				"pageSize":'',
				"pageIndex":''
		};
		//第一个参数请求路径，第二个是传入的参数，第三个是回调函数
		self.DataGrid = new RIT.eW.DataGridAjax(url, 20, self.finMenu);
		self.finMenu = function(result){
			console.log(result);
			var data = result;
			if(data && data.length && data.length>0){
				$.each(data, function (index, val) { val.checked = false; });
			}
			var items = ko.mapping.fromJS(data);
			return items();
		}
		//定义payinfoModel
		self.payinfoModel = ko.observable({
			guid:'',
			orderid:'',
			start:ko.observable(''),
			end:ko.observable('')
		});
		//查询按钮
		self.search = function(){
			self.payinfoModel().start=$("#startDate").val();
			self.payinfoModel().end = $("#endDate").val();
			var data =self.payinfoModel();
			console.log(data);
			self.DataGrid.GridParams.pageIndex(1);
			self.DataGrid.GetData(data);
		};
		self.search();
		//清空按钮
		self.empty = function(){
			self.payinfoModel({
				guid:'',
				orderid:'',
				start:'',
				end:''
			})
		};
		self.payInfoModelLayer = ko.observable({
			guid:'',
			billmode:'',
			paytime:'',
			orderid:'',
			paymenttype:'',
			fee:'',
			modifymark:'',
			remark:'',
			ietype:'',
			monetarytype:'',
			cbecode:'',
			cbename:''
		});
		self.update = function(data){
			console.log(data);
			self.payInfoModelLayer(data);
			layer.open({
				type : 1,
				title:'运单信息',
				skin : 'layui-layer-rim', //加上边框
				area : [ '518px', '417px' ], //宽高
				content :$('#popbg')
			});
			
		}
		self.send = function(data) {
			layer.confirm('确定要重推订单？', {
				btn : [ '确定', '取消' ]
			// 按钮
			}, function() {
			var orderid = data.guid;
			console.log(orderid)
			$.ajax({
				url : '/orderhead/send',
				method : 'POST',
				contentType : 'application/json',
				data : JSON.stringify(orderid),
				success : function(result) {
					layer.closeAll();
					toastr.success(result);
					console.log(result);
				},
			});
			})
		};
		self.save = function(){
			var data =self.payInfoModelLayer();
			console.log(data);
			$.ajax({
				url:"/payinfo/doUpdateObject",
				data:JSON.stringify(data),
				type:"post",
				dataType: "json",
				contentType: 'application/json;charset=UTF-8',
				success:function(result){
					if(result.code ==0){
						toastr.success("修改成功!");
					}
					if(result.code ==1){
						toastr.error("修改失败!");
					}
				}
			});
			self.search();
			self.Cancel();
		}
		self.Cancel = function(){
			layer.close(layer.index);
		}
		self.look = function(data){
			console.log(data.orderid);
			
			$.ajax({
				url:"/payinfo/doFindReceipt",
				data:JSON.stringify(data),
				type:"post",
				dataType: "json",
				contentType: "application/json;charset=UTF-8",
				success:function(result){
					if(result.code == 1){
						toastr.error(result.msg);
						return;
					}
					if(result.code == 0){
						layer.open({
							type : 1,
							title:'运单回执信息',
							skin : 'layui-layer-rim', //加上边框
							area : [ '598px', '600px' ], //宽高
							content :$('#recepipt')
						});
						self.ReceiptModelLayer(result.data);
					}
				}
			});
		}
		self.ReceiptModelLayer = ko.observable({
			expressNumber:'',
			content:''
		});
	}
	var model = new ViewModel();
	ko.applyBindings(model);
})